#include "stdafx.h"
#include "IBitNot.h"
//OpenCV libs
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv/cv.h"

const char * const IBitNot::FunctionNameIBitNot = "Bitwise-Not";

IBitNot::IBitNot(void) 
{
	_fnApi.SetFunctionName(IBitNot::FunctionNameIBitNot);
	_fnApi.SetFunctionDescription("This function inverts every bit the image.");
									//inputs
	_fnApi.AddParamDef(new ProcParamDefString(0, "NULL", "NULL", ProcParamDef::input, 0, 500 ));
									//outputs
	_fnApi.AddParamDef(new ProcParamDefInt(0, ProcParam::attribOutputParamNameResult, "0 is success", ProcParamDef::output, 0, 1));

	_fnApi.Validate();
}


IBitNot::~IBitNot(void)
{

}


bool IBitNot::Process(ImageProcStep *step, bool DebugMode)
{	
	bool rc = false;
	if ((step != '\0') && (step->IsValid()))
	{
		cv::Mat output;
		cv::Mat input = cv::imread(step->GetIntermediateImagePathFilename());	


		cv::bitwise_not(input, output);

		cv::imwrite(step->GetIntermediateImagePathFilename(), output);
				
		input.release();
		output.release();
		rc = true;
	}
	return rc;
}

